//
//  CookStepsCell.m
//  FoodCorner
//
//  Created by Summer on 16/3/11.
//  Copyright © 2016年 zhangchao. All rights reserved.
//

#import "CookStepsCell.h"
#import <SDAutoLayout/UIView+SDAutoLayout.h>
@implementation CookStepsCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self  addAllViews];
    }
    return self;
}
- (void)addAllViews
{
    _stepNumber = [UILabel new];
    _stepNumber.text = @"1";
    _stepNumber.font = [UIFont systemFontOfSize:18];
    _stepNumber.textAlignment = NSTextAlignmentCenter;
    _stepNumber.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:_stepNumber];
    
    _stepInfoList = [UILabel new];
    _stepInfoList.font = [UIFont systemFontOfSize:16];
    _stepInfoList.textAlignment = NSTextAlignmentCenter;
    _stepInfoList.backgroundColor = [UIColor cyanColor];
    [self.contentView addSubview:_stepInfoList];
    
    _stepImageView = [UIImageView new];
    _stepImageView.backgroundColor = [UIColor redColor];
    _stepImageView.image = [UIImage imageNamed:@"placeholder"];
    [self.contentView addSubview:_stepImageView];
    
    _addInfoListAction = [UIButton buttonWithType:(UIButtonTypeContactAdd)];;
    [self.contentView addSubview:_addInfoListAction];
    
    _lineView = [UIView new];
    //    _lineView.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:_lineView];

    
    CGFloat margin = 10;
    _stepNumber.sd_layout
    .topSpaceToView(self.contentView,margin)
    .leftSpaceToView(self.contentView,margin)
    .widthIs(20)
    .heightIs(20);
    
    _stepImageView.sd_layout
    .leftSpaceToView(self.stepNumber,margin)
    .topSpaceToView(self.contentView,margin)
    .widthIs(150)
    .heightIs(150);
    
    _addInfoListAction.sd_layout
    .topSpaceToView(self.stepImageView,margin)
    .leftSpaceToView(self.contentView,margin)
    .widthIs(15)
    .heightIs(15);
    
    _stepInfoList.sd_layout
    .leftSpaceToView(self.addInfoListAction,margin)
    .rightSpaceToView(self.contentView,margin)
    .topSpaceToView(self.stepImageView,margin / 2)
    .autoHeightRatio(0);
    
    
    _lineView.sd_layout
    .topSpaceToView(_stepInfoList,margin)
    .rightSpaceToView(self.contentView,0)
    .leftSpaceToView(self.contentView,0)
    .heightIs(1);
    
    [self setupAutoHeightWithBottomView:_lineView bottomMargin:margin * 2];

    
}


@end
